package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.hjq.shape.view.ShapeImageView;
import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.HomeCourseListApi;
import com.jjb.www.http.glide.GlideApp;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class CourseListAdapter extends AppAdapter<HomeCourseListApi.Bean> {

    public CourseListAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeImageView mImgThumb;
        private ShapeTextView mTvTitle;
        private ShapeTextView mTvCateText;
        private ShapeTextView mTvMoney;


        private ViewHolder() {
            super(R.layout.item_course);
            mImgThumb = findViewById(R.id.img_thumb);
            mTvTitle = findViewById(R.id.tv_title);
            mTvCateText = findViewById(R.id.tv_cate_text);
            mTvMoney = findViewById(R.id.tv_money);

        }

        @Override
        public void onBindView(int position) {
            HomeCourseListApi.Bean bean = getItem(position);
            GlideApp.with(getContext())
                    .load(bean.getThumb())
                    .into(mImgThumb);
            mTvTitle.setText(bean.getTitle());
            mTvCateText.setText(bean.getCate_text());
            if ("0.00".equals(bean.getAndroid_money())){
                mTvMoney.setText("限时免费");
            }else {
                mTvMoney.setText(bean.getAndroid_money());
            }
        }
    }
}